package sanshui.system.trade.factory.trade.riskCtr;

import org.apache.logging.log4j.util.Strings;
import sanshui.system.trade.factory.trade.indicator.IndicatorCode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public enum RiskCtrCode {
    DEFAULT("DEFAULT", "默认策略", new ArrayList<>()),
    WEN_CAI_RISK("WEN_CAI_RISK", "问财风控策略", new ArrayList<>()),
    TURTLE_ATR("TURTLE_ATR", "海龟策略动态波动", Arrays.asList(IndicatorCode.ATR14, IndicatorCode.TR));

    private String code;
    private String message;
    private List<IndicatorCode> indicatorCodes;

    RiskCtrCode(String code, String message, List<IndicatorCode> indicatorCodes){
        this.code = code;
        this.message = message;
        this.indicatorCodes = indicatorCodes;
    }
    public RiskCtrCode codeOf(String code){
        if (Strings.isEmpty(code)){
            return RiskCtrCode.DEFAULT;
        }
        for (RiskCtrCode value : RiskCtrCode.values()) {
            if (value.getCode().equalsIgnoreCase(code)){
                return value;
            }
        }
        return RiskCtrCode.DEFAULT;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public List<IndicatorCode> getIndicatorCodes() {
        return indicatorCodes;
    }

    public List<IndicatorCode.Type> getRiskCtlNames() {
        List<IndicatorCode.Type> res = new ArrayList<>();
        for (IndicatorCode indicatorCode : indicatorCodes) {
            res.add(indicatorCode.getName());
        }
        return res;
    }
}
